local skel = fk.CreateSkill {
  name = "efengqi__luoshen",
}

Fk:loadTranslationTable{
  ["efengqi__luoshen"] = "洛神",
  [":efengqi__luoshen"] = "当你获得牌后，你可以进行一次判定。若结果为黑，你分配之，若不为黑则本回合此技能失效。你以此获得的牌本回合不计上限。",

  ["#efengqi__luoshen-give"] = "洛神：令一名角色获得%arg，点取消给自己",
  ["@@efengqi__luoshen-inhand-turn"] = "洛神",

  ["$efengqi__luoshen1"] = "髣髴兮若轻云之蔽月。",
  ["$efengqi__luoshen2"] = "飘飖兮若流风之回雪。",
}

skel:addEffect(fk.AfterCardsMove, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(skel.name) then
      for _, move in ipairs(data) do
        if move.to == player and move.toArea == Card.PlayerHand then
          return true
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local judge = {
      who = player,
      reason = skel.name,
      pattern = ".|.|spade,club",
      skipDrop = true,
    }
    room:judge(judge)
    if player.dead or not judge.card then return end
    if judge.card.color == Card.Black then
      if room:getCardArea(judge.card) == Card.Processing then
        local tos = room:askToChoosePlayers(player, {
          min_num = 1, max_num = 1, skill_name = skel.name, targets = room.alive_players,
          prompt = "#efengqi__luoshen-give:::"..judge.card:toLogString()
        })
        local to = tos[1] or player
        room:obtainCard(to, judge.card, true, fk.ReasonGive, player, skel.name,
        to == player and "@@efengqi__luoshen-inhand-turn" or nil)
      end
    else
      room:invalidateSkill(player, skel.name, "-turn")
      if room:getCardArea(judge.card) == Card.Processing then
        room:moveCardTo(judge.card, Card.DiscardPile, nil, fk.ReasonJudge)
      end
    end
  end,
})

skel:addEffect("maxcards", {
  exclude_from = function(self, player, card)
    return card:getMark("@@efengqi__luoshen-inhand-turn") > 0
  end,
})

return skel
